#pragma once
#include <YSimpleSystem/YProactorToken.h>
#include <WinSock2.h>
#include <YSimpleNetwork/YEndPoint.h>

namespace ysimple_network
{
	struct IRecvFromCallback;
	struct IUDPSession;

	class YProactorTokenOnRecvFrom :
		public ysimple_system::YProactorToken
	{
		IRecvFromCallback*	m_pCallback;
		WSABUF			m_wsabuf;
		char				m_buf[1024*4];
		IUDPSession*			m_pSession;
		SOCKADDR		m_fromSockAddr;
		int					m_fromSockAddrSize;
	public:
		YProactorTokenOnRecvFrom(void);
		virtual ~YProactorTokenOnRecvFrom(void);

		void				beginInit(IRecvFromCallback& callback, IUDPSession& session);		
		void				endInit(bool success);
		bool				onCompleted(bool completionStatus, LONG_PTR		completionKey, DWORD			dwBytesTransfered ) override;
		WSABUF&		getWSABuf();
		DWORD			getWSABufCount();
		SOCKADDR*		getSockAddr();
		int*				getSockAddrSize();
	};


}
